package chen.web.user;

/**
 * 系统内置帐号．包括公共的访客帐号以及拥有所有权限的系统帐号．
 * @author chen
 *
 */
public class InternalAccountProvider {

	private static final int PublicGuestAccountId = 1;
	private static final int SystemAccountId = 2;
	
	private static AccountManager accountManager;
	public static void setAccoutManager(AccountManager accountManager){
		InternalAccountProvider.accountManager = accountManager;
	}
	
	public static Account getPublicGuestAccount(){
		Account publicGuestAccount =accountManager.getAccount(PublicGuestAccountId);
		if(publicGuestAccount == null){
			throw new RuntimeException("数据库基础数据丢失，找不到公共访客帐号，帐号id:" + PublicGuestAccountId);
		}
		return publicGuestAccount;
	}
	
	public static Account getSystemAccount(){
		Account systemAccount = accountManager.getAccount(SystemAccountId);
		if(systemAccount == null){
			throw new RuntimeException("数据库基础数据丢失，找不到系统帐号，帐号id:" + SystemAccountId);
		}
		return systemAccount;
	}
}
